package io.renren.modules.interset.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.interset.entity.IntersetEntity;
import io.renren.modules.interset.service.IntersetService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("interset/interset")
public class IntersetController {

    @Autowired
    private HttpServletRequest request;


    @Autowired
    private IntersetService intersetService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("interset:interset:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = intersetService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{no}")
    @RequiresPermissions("interset:interset:info")
    public R info(@PathVariable("no") Integer no){
		IntersetEntity interset = intersetService.getById(no);

        return R.ok().put("interset", interset);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("interset:interset:save")
    public R save(@RequestBody IntersetEntity interset){
		intersetService.save(interset);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("interset:interset:update")
    public R update(@RequestBody IntersetEntity interset){
		intersetService.updateById(interset);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("interset:interset:delete")
    public R delete(@RequestBody Integer[] nos){
		intersetService.removeByIds(Arrays.asList(nos));

        return R.ok();
    }

}
